package com.project.zsxd.server.common.enums;

import org.apache.tomcat.util.http.parser.Authorization;

/**
 * 返回结果枚举
 * Created by kaler on 2020/3/27.
 */
public enum ResultEnum {

    /** 系统相关 */
    SYSTEM_ERROR("SYSTEM_ERROR", "系统错误"),

    /** 检验相关 */
    ARGUEMENTS_ERROR("ARGUEMENTS_ERROR", "参数错误"),

    /** 用户相关 */
    USER_NOT_EXISTS("USER_NOT_EXISTS", "用户不存在"),
    USER_AUTHENTICATION_ERROR("USER_AUTHENTICATION_ERROR", "用户认证失败"),
    USER_AUTHORIZATION_ERROR("USER_AUTHORIZATION_ERROR", "用户权限不足"),
    USER_TOKEN_EXPIRED("USER_TOKEN_EXPIRED", "用户TOKEN已过期"),

    /** 打卡相关 */
    SLEEP_CLOCKED("SLEEP_CLOCKED", "今日已打卡"),
    /** 补卡相关 */
    FILL_CLOCK_DATE("HISTORY_CLOCK_DATE", "打卡日期不正确"),
    FILL_CLOCKED("HISTORY_CLOCKED", "该日已打卡"),
    FILL_CLOCK_OUT_LIMIT("FILL_CLOCK_OUT_LIMIT", "补卡次数不足"),

    /** 文件上传相关 */
    FILE_UPLOAD_ERROR("FILE_UPLOAD_ERROR", "文件上传失败"),
    ;


    private String code;
    private String message;

    ResultEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ResultEnum getEnumByCode(String code) {
        for (ResultEnum enums: ResultEnum.values()) {
            if (enums.getCode().equals(code)) {
                return enums;
            }
        }
        return null;
    }
}
